/*    */ package com.zimbra.cs.service.account;
/*    */ 
/*    */ import com.zimbra.common.account.Key.IdentityBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AccountConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.SoapFaultException;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.Identity;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.soap.DocumentHandler;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class DeleteIdentity
/*    */   extends DocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException, SoapFaultException
/*    */   {
/* 37 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 38 */     Account account = getRequestedAccount(zsc);
/*    */     
/* 40 */     if (!canModifyOptions(zsc, account)) {
/* 41 */       throw ServiceException.PERM_DENIED("can not modify options");
/*    */     }
/* 43 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/* 45 */     Element eIdentity = request.getElement("identity");
/*    */     
/*    */ 
/* 48 */     Identity ident = null;
/* 49 */     String idStr = eIdentity.getAttribute("id", null);
/* 50 */     if (idStr != null) {
/* 51 */       ident = prov.get(account, Key.IdentityBy.id, idStr);
/*    */     } else {
/* 53 */       idStr = eIdentity.getAttribute("name");
/* 54 */       ident = prov.get(account, Key.IdentityBy.name, idStr);
/*    */     }
/*    */     
/* 57 */     if (ident != null) {
/* 58 */       Provisioning.getInstance().deleteIdentity(account, ident.getName());
/*    */     } else {
/* 60 */       throw AccountServiceException.NO_SUCH_IDENTITY(idStr);
/*    */     }
/* 62 */     Element response = zsc.createElement(AccountConstants.DELETE_IDENTITY_RESPONSE);
/* 63 */     return response;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/account/DeleteIdentity.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */